package com.jacob.androidframe.controls;

import com.jacob.androidframe.R;

import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Color;
import android.graphics.Paint;
import android.util.AttributeSet;
import android.view.View;

public class RoundChronometer extends View {
	
	public static final int APPEARANCE_RING = 1;  
    public static final int APPEARANCE_SOLID = 2;
    public static final int TIME_UNIT_SECOND = 1;  
    public static final int TIME_UNIT_MINUTE = 2;
    public static final int COUNT_MODE_UP = 1;
    public static final int COUNT_MODE_DOWN = 2;
    
    public static final int DEFAULT_APPEARANCE = APPEARANCE_RING;
    public static final int DEFAULT_TIME_UNIT = TIME_UNIT_SECOND;
    public static final int DEFAULT_COUNT_MODE = COUNT_MODE_DOWN;
    public static final int DEFAULT_TIME = 5;
    public static final String DEFAULT_TEXT = "%1$d";
    public static final int DEFAULT_TEXT_COLOR = Color.parseColor("#FFE2F4FB");
    public static final float DEFAULT_TEXT_SIZE = 15;
    public static final int DEFAULT_RING_COLOR = Color.parseColor("#00000000");
    public static final float DEFAULT_RING_WIDTH = 3;
    public static final int DEFAULT_PROGRESS_COLOR = Color.parseColor("#FFE2F4FB");
    public static final int DEFAULT_BG_COLOR = Color.parseColor("#00000000");
    
    private int mAppearance;
    private int mTimeUnit;
	private int mCountMode;
	private String mText;
    private int mTextColor;
    private float mTextSize;
    private int mRingColor;
    private float mRingWidth;
    private int mProgressColor;
    private int mBackgroundColor;
    private boolean mIsStarted;
    private Paint mPaint;

	public RoundChronometer(Context pContext) {
		this(pContext, null, 0);
		
	}

	public RoundChronometer(Context pContext, AttributeSet pAttributeSet) {
		this(pContext, pAttributeSet, 0);
	}

	public RoundChronometer(Context pContext, AttributeSet pAttributeSet, int pDefStyle) {
		super(pContext, pAttributeSet, pDefStyle);

		TypedArray _TypedArray = pContext.obtainStyledAttributes(pAttributeSet, R.styleable.RoundChronometer, pDefStyle, 0);
		mAppearance = _TypedArray.getInt(R.styleable.RoundChronometer_appearance, DEFAULT_APPEARANCE);
		mTimeUnit = _TypedArray.getInt(R.styleable.RoundChronometer_timeUnit, DEFAULT_TIME_UNIT);
		mCountMode = _TypedArray.getInt(R.styleable.RoundChronometer_countMode, DEFAULT_COUNT_MODE);
		mText = _TypedArray.getString(R.styleable.RoundChronometer_text);
		mTextColor = _TypedArray.getColor(R.styleable.RoundChronometer_text, DEFAULT_TEXT_COLOR);
		mTextSize = _TypedArray.getDimension(R.styleable.RoundChronometer_textSize, DEFAULT_TEXT_SIZE);
		mRingColor = _TypedArray.getColor(R.styleable.RoundChronometer_ringColor, DEFAULT_RING_COLOR);
		mRingWidth = _TypedArray.getDimension(R.styleable.RoundChronometer_ringWidth, DEFAULT_RING_WIDTH);
		mProgressColor = _TypedArray.getColor(R.styleable.RoundChronometer_progressColor, DEFAULT_PROGRESS_COLOR);
		mBackgroundColor = _TypedArray.getColor(R.styleable.RoundChronometer_backgroundColor, DEFAULT_BG_COLOR);
		_TypedArray.recycle();
		
		mIsStarted = false;
		
		mPaint = new Paint();
	}

}
